package com.hfplm.wyu.utils;

public class ExcelLocation {
	
//	public static void main(String[] args) {
//		String excelstr = "X8";
//		excelStrToNum(excelstr);
//	}
	
	public static int[] excelStrToNum(String excelstr){
		int[] location = null;
		
		if(null != excelstr && excelstr.length()>1){
			String colstr = excelstr.substring(0, 1);
//			System.out.println("colstr:" + colstr);
			int col = strToNum(colstr);
			int row = Integer.parseInt(excelstr.substring(1))-1;
			int[] location1 = {row, col};
//			for(int i=0; i<location1.length; i++){
//				System.out.println(excelstr + "***" + location1[i]);
//			}
			return location1;			
		}
		
		return location;
		
	}
	

	private static int strToNum(String colstr) {
		int num = -1;

		String s = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
		String sm = "abcdefghijklmnopqrstuvwxyz";
		if(s.contains(colstr)){
			num = s.indexOf(colstr);
		}else if(sm.contains(colstr)){
			num = sm.indexOf(colstr);	
			
		}
		
		return num;
	}
	

}
